package com.cgc.venus.server.log.controller;
import com.cgc.venus.server.core.bean.response.VenusResponse;
import com.cgc.venus.server.core.bean.response.VenusResponseStatus;
import com.cgc.venus.server.core.exception.VenusException;
import com.cgc.venus.server.log.bean.OperLog;
import com.cgc.venus.server.log.inter.OperLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * Created by 业哥 on 2017/6/3.
 */
@Api(value = "操作日志管理",description="操作日志管理所对应服务的api")
@RequestMapping("/operLog-admin")
@RestController
public class OperLogController {
    @Autowired
    private OperLogService operLogServiceImpl;
    @ApiOperation("操作日志类型查询")
    @RequestMapping(value = "/operLogType", method = RequestMethod.GET)
    @ResponseBody
    public VenusResponse<List> operLogTypeQuery() throws VenusException {
        List result=operLogServiceImpl.queryOperLogType();
        VenusResponse<List> response=new VenusResponse<List>(VenusResponseStatus.OK,"",result);
        return response;
    }

    @ApiOperation("操作日志查询")
    @RequestMapping(value = "/operLog", method = RequestMethod.GET)
    @ResponseBody
    public VenusResponse<OperLog> operLogQuery(@RequestParam("operType") String operType,
                                               @RequestParam("status") String status,
                                               @RequestParam("timeStart") String timeStart,
                                               @RequestParam("timeEnd") String timeEnd,
                                               @RequestParam(value = "queryKey",required = false) String queryKey,
                                               @RequestParam("currentPage") int currentPage,
                                               @RequestParam(value = "userId",required = false) String userId) throws VenusException {
        OperLog operLog=operLogServiceImpl.queryAppLog(operType,status,timeStart,timeEnd,queryKey,currentPage,userId);
        VenusResponse<OperLog> response=new VenusResponse<OperLog>(VenusResponseStatus.OK,"",operLog);
        return response;
    }

    @ApiOperation("应用操作日志查询")
    @RequestMapping(value = "/appOperLog", method = RequestMethod.GET)
    @ResponseBody
    public VenusResponse<List> appOperLogQuery(@RequestParam("appName") String appName) throws VenusException {
        List list=operLogServiceImpl.queryAppLog(appName);
        VenusResponse<List> response=new VenusResponse<List>(VenusResponseStatus.OK,"",list);
        return response;
    }
}